package com.example.testdemo.designModel;

/**
 * 双重判定 解决
 */
public class SinglonThree {

    public  static  SinglonThree instance;

    public  SinglonThree(){
        System.out.println("======构造方法");
    }

    public  static  SinglonThree getInstance(){
        if(instance==null){
            synchronized (SinglonThree.class){
                if (instance==null){
                    instance=new SinglonThree();
                }
            }
        }
        return  instance;
    }

}

class  TestDemoSin{
    public static void main(String[] args) {
        SinglonThree s1=SinglonThree.getInstance();
        SinglonThree s2=SinglonThree.getInstance();

        System.out.println(s1==s2);
    }
}
